package com.ushine.web.template.desensitization.controller;

import com.ushine.web.component.http.HttpResponseVO;
import com.ushine.web.template.desensitization.model.FieldDesensitizationDO;
import com.ushine.web.template.desensitization.service.IFieldDesensitizationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: yls
 * @Date 2022/2/10 17:35
 * @Description: 数据字段脱敏
 * @Version 1.0
 **/
@RestController
@RequestMapping("component/desensitization")
@Api(tags = "组件模块-字段脱敏测试")
public class FieldDesensitizationController {

    @Resource
    private IFieldDesensitizationService fieldDesensitizationService;

    @ApiOperation(value = "添加数据")
    @PostMapping("inset")
    public HttpResponseVO<Object> insert(@RequestBody FieldDesensitizationDO filedDesensitization) {
        Boolean flag = fieldDesensitizationService.insert(filedDesensitization);
        if (Boolean.TRUE.equals(flag)) {
            return new HttpResponseVO<>().ok("添加成功");
        }
        return new HttpResponseVO<>().ok("添加失败");
    }

    @ApiOperation(value = "查询数据")
    @GetMapping("list")
    public HttpResponseVO<List<FieldDesensitizationDO>> listFieldDesensitizations() {
        List<FieldDesensitizationDO> fieldDesensitizations = fieldDesensitizationService.listFieldDesensitizations();
        return new HttpResponseVO<List<FieldDesensitizationDO>>().ok("", fieldDesensitizations);
    }

}
